﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Com.Qkds.Erp.WebUi
{
    public partial class StorageList : System.Web.UI.Page
    {
        public int pid
        {
            get
            {
                return int.Parse(ViewState["pid"].ToString());
            }
            set
            {
                ViewState["pid"] = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pid = 0;
                if (Request["id"] != null)
                {
                    string TableName = "Storage";
                    pid = int.Parse(Request["id"].ToString());
                    StorageModel model = new StorageBLL().GetModelByID(TableName, pid);
                    this.txtTime.Value = model.Time.ToString();
                    this.txtUser.Value = model.UserID.ToString();
                    this.txtState.Value = model.State.ToString();
                }

            }
        }
        protected void btnSave_click(object sender, EventArgs e)
        {
            StorageModel model = new StorageModel()
            {
                Time = DateTime.Parse(this.txtTime.Value),
                UserID = int.Parse(this.txtUser.Value),
                State = int.Parse(this.txtState.Value),
            };
            StorageBLL bll = new StorageBLL();
            if (pid > 0)
            {
                bll.Gai(model, pid);

            }
            else
            {
                bll.Add(model);


            }
            Response.Redirect("Storage.aspx");
        }
    }
}